package com.mht.book.operation.impl;


import com.mht.book.entity.book.Book;
import com.mht.book.entity.book.BookList;
import com.mht.book.operation.Operations;

import java.util.Scanner;

/**
 * @author wangfusheng
 * @version 1.0.0
 * @ClassName BackBookOperation.java
 * @Description TODO
 * @createTime 2022/12/411:19
 */
public class BackBookOperation implements Operations {

    @Override
    public void work(BookList bookList) {
        System.out.println("归还图书!");
        System.out.println("请输入你要归还的图书：");
        Scanner sc = new Scanner(System.in);
        String inputName = sc.nextLine();
        for (int i = 0; i < bookList.getUsedSize(); i++) {
            Book book = bookList.getBook(i);
            if(book.getName().equalsIgnoreCase(inputName)){
                System.out.println("已查询到您要归还的图书，正在还书，请稍后...");
                book.setIsBorrowed(false);
                System.out.println("还书成功！感谢您如约还书");
                System.out.println();
                return;
            }
        }
        System.out.println("未查询到您要归还的图书...");
        System.out.println();
    }

//    public static void main(String[] args) {
//        BackBookOperation b  = new BackBookOperation();
//        b.work(new BookList());
//    }
}
